<template>
	<view class="user">
		<!-- 上方显示用户信息的区域 -->
		<view class="userinfo">
			<!-- 信息区域 -->
			<view class="top">
				<view class="avator">
					<uni-icons type="person-filled" size="30" :color="logColor"></uni-icons>
				</view>
				<!-- store.userInfo.username是从状态对象中获取已登录用户的信息中的姓名 -->
				<view class="uname" v-if="store.isLogin">
					<view>{{store.userInfo.username}}</view>
				</view>
				<view class="uname" v-else @tap="toLogin">点击登录</view>

			</view>
		</view>
		<!-- 下方显示的四项用户操作项 -->
		<view class="list">
			<uni-list>
				<uni-list-item v-for="item,index in manageList" :title="item.name" :show-extra-icon="true"
					:extra-icon="item.icon" clickable link @tap="navto(index)">
				</uni-list-item>
			</uni-list>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		CONFIG
	} from '../../untils/config.js'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		userStore
	} from '../../store/userStore.js';
	let store = userStore()
	let logColor = ref('#000000')
	const manageList = ref([{
			name: '密码修改',
			icon: {
				color: '#ff6700',
				size: '22',
				type: 'location-filled'
			}
		},
		{
			name: '我的收藏',
			icon: {
				color: '#0225ff',
				size: '22',
				type: 'star'
			}
		},
		{
			name: '设置',
			icon: {
				color: '#0081b9',
				size: '22',
				type: 'gear'
			}
		}
	])
	
	function toLogin() {
	  uni.navigateTo({
	    url: "/pages/login/login"
	  })
	}
</script>

<style lang="scss" scoped>
	.user {
		width: 100%;
		height: 100%;
		background-color: #f8f8f8;
	}

	.userinfo {
		width: 100%;
		height: 200rpx;
		background-color: #ffffff;
	}

	.top {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
	}

	.avator {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		background-color: #f8f8f8;
		margin-left: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.uname {
		margin-left: 20rpx;
		font-size: 40rpx;
		font-weight: 600;
	}

	.list {
		width: 100%;
		height: 100%;
		margin-top: 20rpx;
		background-color: #ffffff;
	}
</style>